package com.yangjun.common.timetask;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.yangjun.dao.mybatis.mapper.businessAnalysis.SemConversionMapper;
import com.yangjun.dao.mybatis.mapper.realtimeLiveAnalysis.KeywordInforMapper;
import com.yangjun.dao.mybatis.mapper.realtimeLiveAnalysis.flowAnalysisMapper;
import com.yangjun.dao.mybatis.mapper.report.ReportMapper;
import com.yangjun.utils.DvDateUtils;

@Component
public class ScheduledDeleteTasks {
	private static Logger logger = Logger.getLogger(ScheduledDeleteTasks.class);  


	@Autowired
	private ReportMapper reportMapper;
	@Autowired
	private KeywordInforMapper keywordInforMapper;
	@Autowired
    private flowAnalysisMapper flowAnalysisMapper;
	@Autowired
	private SemConversionMapper semConversionMapper;
	@Scheduled(cron = "0 30 07 * * *")
    public void clearKeyWordData(){
		System.out.println("开始");
		String date = DvDateUtils.getDate(new Date(),-7);
		reportMapper.deleteSemSourceKeyWordByBeforeDate(date);
		reportMapper.deleteSeoSourceKeyWordByBeforeDate(date);
		
		keywordInforMapper.deleteOutsideKeywordByBeforeDate(date);
		
		flowAnalysisMapper.deleteSearchKeywordByBeforeDate(date);
		flowAnalysisMapper.deleteSearchKeywordNullResultByBeforeDate(date);
		flowAnalysisMapper.deleteSearchKeywordURLByBeforeDate(date);
		
		semConversionMapper.deleteSemRealtimeChannelByBeforeDate(date);
		semConversionMapper.deleteSemRealtimeSalesByBeforeDate(date);
		System.out.println("结束");
    }
}
